package com.tz.farmer.controller;

import com.smartPark.msframe.result.ResultEx;
import com.tz.farmer.service.IFarmerSunDataService;
import com.tz.farmer.so.DefaultSo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/kitchen")
@Api(tags = "阳光厨房接口")
public class FarmerKitchenController {

    private static final String kitchenKey = "kitchenKey";
    private static final String societyKey = "societyKey";
    private static final String schoolKey = "schoolKey";
    private static final String market = "阳光厨房";

    @Autowired
    private IFarmerSunDataService dataService;

    @PostMapping("/set")
    @ApiOperation(value = "设置厨房数量")
    public ResultEx setKitchenConfig(@RequestBody DefaultSo body) {
        dataService.setSunData(body, market, kitchenKey, societyKey, schoolKey);

        return ResultEx.builder().makeSuccessResult();
    }

    @GetMapping("/get")
    @ApiOperation(value = "获取厨房数据")
    public ResultEx getKitchenConfig() {
        Map<String, Object> response = dataService.getSunData(market, kitchenKey, societyKey, schoolKey);

        return ResultEx.builder().makeSuccessResult(response);
    }
}
